package com.ftw.commons.utils

import android.graphics.Color
import com.ftw.commons.widgets.RTextView
import java.util.*

/**
 * 描    述：
 * 作    者：fantianwen
 * 时    间：2019-11-30
 */

object WidgetsUtils {



    /***
     * 依据时间间隔确定，控件颜色
     */
    private fun getColor(rTextView: RTextView, timeMillis: Long) {


        val currentData = Calendar.getInstance()

        val currentYear = currentData.get(Calendar.YEAR)
        val currentDay = currentData.get(Calendar.DATE)
        val currentHour = currentData.get(Calendar.HOUR)

        currentData.time = Date(timeMillis)

        val remoteYear = currentData.get(Calendar.YEAR)
        val remoteDay = currentData.get(Calendar.DATE)
        val remoteHour = currentData.get(Calendar.HOUR)

        var color = "#11C0C0"

        if (currentYear - remoteYear >= 1) {
            color = "#F12B2C"
        }

        if (currentDay - remoteDay > 1) {
            color = "#0FABE5"
        }

        if (currentDay - remoteDay == 1) {
            color = "#0FABE5"
        }

        if (currentHour - remoteHour >= 1) {
            color = "#FFBD01"
        }

        rTextView.setTextColor(Color.parseColor(color))

        rTextView.setBorderColorNormal(Color.parseColor(color))

    }


}